#define _CRT_SECURE_NO_WARNINGS
#include"list.h"
int main()
{
	List* head1 = NULL;
	List* head2 = NULL;
	int n, m;
	cin >> n >> m;
	int i;
	int num = 0;
	for (i = 1; i <= n; i++)
	{
		cin >> num;
		addlist(&head1, num);
	}
	for (i = 1; i <= m; i++)
	{
		cin >> num;
		addlist(&head2, num);
	}
	/*printlist(&head1);
	printlist(&head2);*/
	List*newhead=combine_list(&head1, &head2);
	printlist(&newhead);

	system("pause");
}